<?php
  require_once '../../Helpers/DbHelper.php';
  require_once '../../Helpers/PathHelper.php';
  require_once '../../Controllers/UserController.php';

  $u = new UserController();
  $u->evaluatePagePermission(UserController::ADMINISTRATOR);
  //
  require_once '../../Controllers/EnrolmentController.php';
  require_once '../../Controllers/AdminController.php';
  require_once '../../Controllers/SchoolController.php';
  //
	$c = new EnrolmentController();
	$a = new AdminController();
	//
  $yearLevelElem = $a->getYearLevelByDepartment(SchoolController::ELEMENTARY);
  $yearLevelPreElem = $a->getYearLevelByDepartment(SchoolController::PRE_ELEMENTARY);

  if(isset($_POST) && !empty($_POST))
	{
	  $message = $c->enrol(EnrolmentController::CREATE);
	  $id = $_POST['student-id'];
	}
?>
<html>
  <title>School Enrollment :: Enrollment Form</title>
  <head>
    <link type="text/css" href="../../assets/styles.css" rel="stylesheet">
    <link type="text/css" href="../../assets/tabs.css" rel="stylesheet">
    <base href="../../" target="">
    <script type="text/javascript" src="assets/js/jquery-1.6.2.min.js"></script>
    <script type="text/javascript" src="../../assets/js/jquery-ui-1.8.16.custom.min.js"></script>
    <script type="text/javascript" src="../../assets/js/jquery.ui.tabs.js"></script>
    <script type="text/javascript">
      $(document).ready(function()
      {
      	//When page loads...
      	//$('.enrolment-form').hide();
        $('#enrolment-status-pre,#enrolment-status-elem').attr('checked', false);
      	$(".tab_content").hide(); //Hide all content
      	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
      	$(".tab_content:first").show(); //Show first tab content
        //On Open Enrolment
        $('#enrolment-status-pre').click(function()
        {
          $('#prelem').slideToggle();
        });
        $('#enrolment-status-elem').click(function()
        {
          $('#elem').slideToggle();
        });
      	$("ul.tabs li").click(function()
      	{
      		$("ul.tabs li").removeClass("active"); //Remove any "active" class
      		$(this).addClass("active"); //Add "active" class to selected tab
      		$(".tab_content").hide(); //Hide all tab content

      		var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
      		$(activeTab).fadeIn(); //Fade in the active ID content
      		return false;
      	});
      });
    </script>
  </head>
  <body>
    <div class="admin-container">
    <?php
       require_once '../commons.php';
       renderAdminNav();
     ?>
     </div>
    <div class="container">
      <ul class="tabs">
          <li><a href="#tab1">Pre-Elementary</a></li>
          <li><a href="#tab2">Elementary</a></li>
      </ul>
      <div class="tab_container">
          <div id="tab1" class="tab_content">
              <!--Content-->
              <div class="open-enrolment"><input type="radio" name="enrolment-status" id="enrolment-status-pre" />
                Show Enrollment Form</div><br />
                <?php if($message) {?><div align="center"><strong>STUDENT WAS SUCCESSFULLY ENROLLED.PLEASE PROCEED WITH THE NEXT STEP.</strong></div><?php } ?>
                <?php if($id) {?> <a id="prev-next" href="<?php echo PathHelper::getBaseUrl().'/Views/Admin/student_requirements.php?id='.$id?>">Next Step &rarr;</a><?php }?>
                <form name="enrolment-form" class="enrolment-form" id="prelem" method="post" action="">
                  <table cellpadding="0" align="center">
                    <tr>
                      <th>Enrolment Form</th>
                    </tr>
                    <tr>
                      <td><label for="student-id">Student ID:</td>
                      <td><input type="text" name="student-id" class="student-id"/></td>
                    </tr>
                    <tr>
                      <td><label for="school-year">School Year:</label></td>
                      <td><input type="text" name="school-year" /></td>
                      <td colspan="2">
                        <label for="grade-level">Choose a level: </label>
                        <select name="grade-level">
                          <?php
                           while($rows=mysql_fetch_assoc($yearLevelPreElem))
                            {
                              $content = "";
                              $content.='<option value="'.$rows['YearLevelId'].'"';
                              $content.='>'.$rows['YearLevelDescription'].'</option>';
                              echo $content;

                            }
                          ?>
                        </select>
                      </td>
                    </tr>
                    <tr>
                      <td colspan="2">
                        <input type="radio" name="status" checked/>New Student
                        <input type="radio" name="status" />Old Student
                      </td>
                    </tr>
                    <tr><td>&nbsp;</td></tr>
                    <tr>
                      <th colspan="2">Child's Details</th>
                    </tr>
                    <tr>
                      <td><label for="name">Student's Name: </label></td>
                      <td><input type="text" name="name" /></td>
                      <td><label for="birth-date">Birth Date: </label></td>
                      <td><input type="text" name="birth-date" /></td>
                    </tr>
                    <tr>
                      <td><label for="nickname">Nickname: </label></td>
                      <td><input type="text" name="nickname" /></td>
                      <td><label for="age">Age:</label></td>
                      <td><input type="text" name="age" /></td>
                    </tr>
                    <tr>
                      <td><label for="home-number">Home Phone Number: </label></td>
                      <td><input type="text" name="home-number" /></td>
                      <td><label for="address">Address:</label></td>
                      <td><input type="text" name="address" /></td>
                    </tr>
                    <tr>
                      <td><label for="religion">Religion:</label></td>
                      <td><input type="text" name="religion" /></td>
                      <td><label for="nationality">Nationality:</label></td>
                      <td><input type="text" name="nationality" /></td>
                    </tr>
                    <tr>
                      <td><label for="sex">Sex: </label></td>
                      <td>
                        <input type="radio" name="sex" value="male" checked />Male
                        <input type="radio" name="sex" value="female"/>Female
                      </td>
                    </tr>
                    <tr>
                      <td><label for="school-attended">School attended <br />(if transferee): </label></td>
                      <td><input type="text" name="school-attended" /></td>
                      <td><label for="school-year-attended">SY: </label></td>
                      <td><input type="text" name="school-year-attended" /></td>
                    </tr>
                    <tr>
                      <td><label for="lives-with">Student primarily lives with: </label></td>
                      <td>
                        <input type="radio" name="lives-with" checked/>Both Parents<br />
                        <input type="radio" name="lives-with" />Mother only<br />
                        <input type="radio" name="lives-with" />Father only <br />
                        <input type="radio" name="lives-with" />Other <br />
                        <label for="lives-with-specify">Specify</label><input type="text" name="lives-with-specify" />
                      </td>
                    </tr>
                    <tr>
                      <th colspan="2">Parent's/Carer's Details</th>
                    </tr>
                    <tr>
                      <td><label for="fathers-name">Father's Name: </label></td>
                      <td><input type="text" name="fathers-name"  /></td>
                      <td><label for="fathers-cellphone">Cellphone No.</label></td>
                      <td><input type="text" name="fathers-cellphone" /></td>
                    </tr>
                    <tr>
                      <td><label for="fathers-occupation">Occupation: </label></td>
                      <td><input type="text" name="fathers-occupation" /></td>
                      <td><label for="fathers-office-number">Office Phone No.</label></td>
                      <td><input type="text" name="fathers-office-number" /></td>
                    </tr>
                    <tr>
                      <td><label for="mothers-name">Mother's Name:</label></td>
                      <td><input type="text" name="mothers-name" /></td>
                      <td><label for="mothers-cellphone">Cellphone No.</label></td>
                      <td><input type="text" name="mothers-cellphone" /></td>
                    </tr>
                    <tr>
                      <td><label for="mothers-occupation">Occupation: </label></td>
                      <td><input type="text" name="mothers-occupation" /></td>
                      <td><label for="mothers-office-number">Office Phone No.</label></td>
                      <td><input type="text" name="mothers-office-number" /></td>
                    </tr>
                    <tr>
                      <td colspan="4"><p>Who will pick up the child from classes? Please list names and mobile phone numbers.</p></td>
                    </tr>
                    <tr>
                      <td><label for="guardian-name[]">1. Name:</label></td>
                      <td><input type="text" name="guardian-name[]" /></td>
                      <td><label for="guardian-cellphone[]">Cellphone No.</label></td>
                      <td><input type="text" name="guardian-cellphone[]" /></td>
                    </tr>
                    <tr>
                      <td><label for="guardian-relationship[]">Relationship to child:</label></td>
                      <td><input type="text" name="guardian-relationship[]" /></td>
                    </tr>
                    <tr>
                      <td><label for="guardian-name[]">2. Name:</label></td>
                      <td><input type="text" name="guardian-name[]" /></td>
                      <td><label for="guardian-cellphone[]">Cellphone No.</label></td>
                      <td><input type="text" name="guardian-cellphone[]" /></td>
                    </tr>
                    <tr>
                      <td><label for="guardian-relationship[]">Relationship to child:</label></td>
                      <td><input type="text" name="guardian-relationship[]" /></td>
                    </tr>
                    <tr>
                      <td colspan="4">
                        <h3><strong>EMERGENCY CONTACTS</strong></h3><br />
                        <em>The emergency contact person must be somebody other than the parents.</em>
                      </td>
                    </tr>
                    <tr>
                      <td><label for="emergency-guardian-name[]">1. Name:</label></td>
                      <td><input type="text" name="emergency-guardian-name[]" /></td>
                      <td><label for="emergency-guardian-cellphone[]">Home/Cellphone No.</label></td>
                      <td><input type="text" name="emergency-guardian-cellphone[]" /></td>
                    </tr>
                    <tr>
                      <td><label for="emergency-guardian-relationship[]">Relationship to child:</label></td>
                      <td><input type="text" name="emergency-guardian-relationship[]" /></td>
                    </tr>
                    <tr>
                      <td><label for="emergency-guardian-name[]">2. Name:</label></td>
                      <td><input type="text" name="emergency-guardian-name[]" /></td>
                      <td><label for="emergency-guardian-cellphone[]">Home/Cellphone No.</label></td>
                      <td><input type="text" name="emergency-guardian-cellphone[]" /></td>
                    </tr>
                    <tr>
                      <td><label for="emergency-guardian-relationship[]">Relationship to child:</label></td>
                      <td><input type="text" name="emergency-guardian-relationship[]" /></td>
                    </tr>
                    <tr>
                      <td colspan="4"><h3><strong>GENERAL INFORMATION ABOUT YOUR CHILD</strong></h3></td>
                    </tr>
                    <tr>
                      <td colspan="2"><label for="child-allergies">Does your child have any allergies?</label></td>
                      <td>
                        <input type="radio" name="has-allergies" value="Yes"/>Yes
                        <input type="radio" name="has-allergies" value="No"  checked/>No
                      </td>
                    </tr>
                    <tr>
                      <td colspan="4"><p>If YES, please provide a detailed explanation of signs,symptoms and treatment needed.</p></td>
                    </tr>
                    <tr><td colspan="3"><textarea name="allergy-details" cols="40" rows="10"></textarea></td>
                    </tr>
                    <tr>
                      <td colspan="2"><label for="child-medical-condition">Does your child have any medical condition/impairment/disability that you feel we need to know about?</label></td>
                      <td>
                        <input type="radio" name="has-medical-conditions" value="Yes"/>Yes
                        <input type="radio" name="has-medical-conditions" value="No" checked/>No
                      </td>
                    </tr>
                    <tr>
                      <td colspan="4"><p>If YES - please provide a detailed explanation of what it is for and if there are any details our staff should know in order to provide care for your child and special understanding where needed.</p></td>
                    </tr>
                    <tr><td colspan="3"><textarea name="has-medical-condition-details" cols="40" rows="10"></textarea></td></tr>
                    <tr>
                      <td colspan="2"><label for="child-behavior-issues">Does your child have behavior management issues?</label><br />
                       <em> (Example - ADHD, fears or phobias, non-responsive, uncooperative etc.)</em>
                        </td>
                      <td>
                        <input type="radio" name="has-behavior-issues" value="Yes"/>Yes
                        <input type="radio" name="has-behavior-issues" value="No" checked />No
                      </td>
                    </tr>
                    <tr>
                      <td colspan="4"><p>If YES - please specify what medical condition, who it was diagnosed by, how it affects your child and management plans are in place including medication.</p></td>
                    </tr>
                    <tr><td colspan="3"><textarea name="has-behavior-issues-details" cols="40" rows="10"></textarea></td></tr>
                    <tr>
                      <td colspan="4"><p>What other information(s) regarding your child that you feel our staff should be aware of?</p></td>
                    </tr>
                    <tr>
                      <td colspan="3"><textarea name="child-info-others" rows="10" cols="40"></textarea></td>
                    </tr>
                    <tr>
                      <td colspan="4"><p>What are you expecting your child will gain from attending Preschool?</p></td>
                    </tr>
                    <tr>
                      <td colspan="3"><textarea name="parent-expectations" rows="10" cols="40"></textarea></td>
                    </tr>
                    <tr>
                      <td><input type="submit" name="pre-elem-form" value="Save Form Details" /></td>
                    </tr>
                  </table>
                </form>
          </div>
          <div id="tab2" class="tab_content">
              <!--Content-->
            <input type="radio" name="enrolment-status" id="enrolment-status-elem"/>Open Elementary Enrollment Form
              <form name="enrolment-form" class="enrolment-form" id="elem" method="post" action="">
                <table cellpadding="0" align="center">
                  <tr>
                    <th>ENROLLMENT FORM</th>
                  </tr>
                  <tr>
                    <td><label for="student-id">Student ID:</td>
                    <td><input type="text" name="student-id" /></td>
                  </tr>
                  <tr>
                    <td><label for="school-year">School Year:</label></td>
                    <td><input type="text" name="school-year" /></td>
                    <td><label for="grade">Grade:</label></td>
                    <td>
                      <select name="grade-level">
                        <?php
                         while($rows=mysql_fetch_assoc($yearLevelElem))
                          {
                            $content = "";
                            $content.='<option value="'.$rows['YearLevelId'].'"';
                            $content.='>'.$rows['YearLevelDescription'].'</option>';
                            echo $content;

                          }
                          ?>
                      </select>
                    </td>
                  </tr>
                  <tr>
                    <td colspan="3">
                    <input type="radio" name="status" value="New" checked/>New Student
                    <input type="radio" name="status" value="Old" />Old Student
                    <input type="radio" name="status" value="Returning" />Returning Student
                    </td>
                    </tr>
                    <tr><td>&nbsp;</td></tr>
                    <tr>
                    <th colspan="2">STUDENT'S DETAILS</th>
                  </tr>
                 <tr>
                   <td><label for="name">Student's Name: </label></td>
                   <td><input type="text" name="name" /></td>
                   <td><label for="birth-date">Birth Date: </label></td>
                   <td><input type="text" name="birth-date" /></td>
                 </tr>
                 <tr>
                   <td><label for="nickname">Nickname: </label></td>
                   <td><input type="text" name="nickname" /></td>
                   <td><label for="age">Age:</label></td>
                   <td><input type="text" name="age" /></td>
                 </tr>
                  <tr>
                    <td><label for="home-number">Home Phone Number: </label></td>
                    <td><input type="text" name="home-number" /></td>
                    <td><label for="address">Address:</label></td>
                    <td><input type="text" name="address" /></td>
                  </tr>
                  <tr>
                    <td><label for="religion">Religion:</label></td>
                    <td><input type="text" name="religion" /></td>
                    <td><label for="nationality">Nationality:</label></td>
                    <td><input type="text" name="nationality" /></td>
                  </tr>
                  <tr>
                   <td><label for="sex">Sex: </label></td>
                   <td>
                     <input type="radio" name="sex" value="male" checked/>Male
                     <input type="radio" name="sex" value="female" />Female
                   </td>
                  </tr>
                  <tr>
                   <td><label for="school-attended">School attended (if transferee) <br />(if transferee): </label></td>
                   <td><input type="text" name="school-attended" /></td>
                   <td><label for="school-year-attended">SY: </label></td>
                   <td><input type="text" name="school-year-attended" /></td>
                  </tr>
                  <tr>
                   <td><label for="lives-with">Student primarily lives with: </label></td>
                   <td colspan="2">
                     <input type="radio" name="lives-with" value="both" checked />Both Parents<br />
                     <input type="radio" name="lives-with" value="mother" />Mother only<br />
                     <input type="radio" name="lives-with" value="father" />Father only <br />
                     <input type="radio" name="lives-with" value="others" />Others <br />
                     <label for="lives-with-specify">Specify: </label>
                     <input type="text" name="lives-with-specify" />
                   </td>
                  </tr>
  		            <tr>
                    <td><label for="parents-absence-reason">If both parents are absent, please indicate the reasons of absence by checking one of the answers below: </label></td>
                   <td colspan="2">
                     <input type="radio" name="parents-absence-reason" value="abroad" checked/>Working Abroad<br />
                     <input type="radio" name="parents-absence-reason" value="dead" />Mother or Father is dead<br />
                     <input type="radio" name="parents-absence-reason" value="separated" />Mother and Father are separated<br />
                     <input type="radio" name="parents-absence-reason" value="others" />Others <br />
                     <label for="parents-absence-specify">Specify: </label>
    			          <input type="text" name="parents-absence-specify" />
                   </td>
                 </tr>
  		           <tr>
                   <td><label for="takes-care">If both parents are absent, who takes care of the child? </label></td>
                   <td colspan="2">
                     <input type="radio" name="takes-care" value="Godparents-and-relatives" checked />Godparents &amp; Relatives<br />
                     <input type="radio" name="takes-care" value="Orphan-house" />Orphan House<br />
                     <input type="radio" name="takes-care" value="Older-siblings" />Older Brother and / or Sister<br />
    			           <input type="radio" name="takes-care" value="Not-relatives" />Other peole who are not Relatives<br />
                     <input type="radio" name="takes-care" value="Others" />Others <br />
                     <label for="takes-care-specify">Specify</label>
    			           <input type="text" name="takes-care-specify" />
                   </td>
                 </tr>
                 <tr>
                   <th colspan="2">PARENT'S DETAILS</th>
                 </tr>
                 <tr>
                   <td><label for="fathers-name">Father's Name: </label></td>
                   <td><input type="text" name="fathers-name"  /></td>
                   <td><label for="fathers-cellphone">Cellphone No.</label></td>
                   <td><input type="text" name="fathers-cellphone" /></td>
                 </tr>
                 <tr>
                   <td><label for="fathers-occupation">Occupation: </label></td>
                   <td><input type="text" name="fathers-occupation" /></td>
                   <td><label for="fathers-office-number">Office Phone No.</label></td>
                   <td><input type="text" name="fathers-office-number" /></td>
                 </tr>
                 <tr>
                   <td><label for="mothers-name">Mother's Name:</label></td>
                   <td><input type="text" name="mothers-name" /></td>
                   <td><label for="mothers-cellphone">Cellphone No.</label></td>
                   <td><input type="text" name="mothers-cellphone" /></td>
                 </tr>
               <tr>
                 <td><label for="mothers-occupation">Occupation: </label></td>
                 <td><input type="text" name="mothers-occupation" /></td>
                 <td><label for="mothers-office-number">Office Phone No.</label></td>
                 <td><input type="text" name="mothers-office-number" /></td>
               </tr>
               <tr>
                 <td><label for="married-parents">Married: </label></td>
                 <td colspan="2">
			             <input type="radio" name="married-parents" value="Married" />Yes
                   <input type="radio" name="married-parents" value="Not-married" />No
                  </td>
                </tr>
                <tr>
			            <td><label for="married">If yes, where?: </label></td>
			            <td colspan="2">
			              <input type="radio" name="parents-marriage-type" value="Church"  checked/>Catholic Church
                    <input type="radio" name="parents-marriage-type" value="Civil" />Civil Marriage
                  </td>
               </tr>
               <tr>
                 <td colspan="4">
                   <h3><strong>EMERGENCY CONTACTS</strong></h3><br />
                   <em>The emergency contact person must be somebody other than the parents.</em>
                 </td>
               </tr>
               <tr>
                 <td><label for="emergency-guardian-name[]">1. Name:</label></td>
                 <td><input type="text" name="emergency-guardian-name[]" /></td>
                 <td><label for="emergency-guardian-cellphone[]">Home/Cellphone No.</label></td>
                 <td><input type="text" name="emergency-guardian-cellphone[]" /></td>
               </tr>
               <tr>
                 <td><label for="emergency-guardian-relationship[]">Relationship to child:</label></td>
                 <td><input type="text" name="emergency-guardian-relationship[]" /></td>
               </tr>
               <tr>
                 <td><label for="emergency-guardian-name[]">2. Name:</label></td>
                 <td><input type="text" name="emergency-guardian-name[]" /></td>
                 <td><label for="emergency-guardian-cellphone[]">Home/Cellphone No.</label></td>
                 <td><input type="text" name="emergency-guardian-cellphone[]" /></td>
               </tr>
               <tr>
                 <td><label for="emergency-guardian-relationship[]">Relationship to child:</label></td>
                 <td><input type="text" name="emergency-guardian-relationship[]" /></td>
               </tr>
               <tr>
                 <td colspan="4"><h3><strong>GENERAL INFORMATION ABOUT YOUR CHILD</strong></h3></td>
               </tr>
               <tr>
                 <td colspan="2"><label for="has-allergies">Does your child have any allergies?</label></td>
                 <td>
                   <input type="radio" name="has-allergies" value="Yes"/>Yes
                   <input type="radio" name="has-allergies" value="No" checked />No
                 </td>
               </tr>
               <tr>
                 <td colspan="4"><p>If YES, please provide a detailed explanation of signs,symptoms and treatment needed.</p></td>
               </tr>
               <tr><td colspan="3"><textarea name="allergy-details" cols="40" rows="10"></textarea></td>
               </tr>
               <tr>
                 <td colspan="2"><label for="has-medical-conditions">Does your child have any medical condition/impairment/disability that you feel we need to know about?</label></td>
                 <td>
                   <input type="radio" name="has-medical-conditions" value="Yes"/>Yes
                   <input type="radio" name="has-medical-conditions" value="No" checked />No
                 </td>
               </tr>
               <tr>
                 <td colspan="4"><p>If YES - please provide a detailed explanation of what it is for and if there are any details our staff should know in order to provide care for your child and special understanding where needed.</p></td>
               </tr>
               <tr><td colspan="3"><textarea name="has-medical-condition-details" cols="40" rows="10"></textarea></td></tr>
               <tr>
                 <td colspan="2"><label for="has-behavior-issues">Does your child have behavior management issues?</label><br />
                  <em> (Example - ADHD, fears or phobias, non-responsive, uncooperative etc.)</em>
                   </td>
                 <td>
                   <input type="radio" name="has-behavior-issues" value="Yes"/>Yes
                   <input type="radio" name="has-behavior-issues" value="No" checked/>No
                 </td>
               </tr>
               <tr>
                 <td colspan="4"><p>If YES - please specify what medical condition, who it was diagnosed by, how it affects your child and management plans are in place including medication.</p></td>
               </tr>
               <tr><td colspan="3"><textarea name="has-behavior-issues-details" cols="40" rows="10"></textarea></td></tr>
               <tr>
                 <td colspan="4"><p>What other information(s) regarding your child that you feel our staff should be aware of?</p></td>
               </tr>
               <tr>
                 <td colspan="3"><textarea name="child-info-others" rows="10" cols="40"></textarea></td>
               </tr>
               <tr>
                 <td><input type="submit" name="elem-form" value="Save Form Details" /></td>
               </tr>
             </table>
           </form>
          </div>
      </div><!--end of tab container -->
    </div><!--end of container -->
  </body>
</html>
